home *** CD-ROM | disk | FTP | other *** search
/ Beginning Mac Programming / Beginning Mac Programming.bin / Open Me for REALbasic 3 / REALbasic 3.2 / Example Projects / Techniques / Example by Cortis Clark / Make your code faster! / Read Me
Text File  |  2000-04-07  |  1KB  |  30 lines

  1. In college I had an assignment to draw fractals.  When I started working at REAL Software, I thought it would be fun to do it using REALbasic.  I had it working in REALbasic in about an hour.  I had added threads, zooming (just click the start point and end point of the rectangle you want to zoom on), and drag and drop in a couple of more hours.  All in all it was great, but it was slow.
  2.  
  3. I set about to optimize the code.
  4.  
  5. I removed the complex class and used X and Y instead.
  6. I in-lined the complexsquare function
  7. I in-lined the iterate function
  8. I used singles instead of doubles (this is slightly faster on PowerPC, but much slower on 68k)
  9. I drew into an offscreen picture
  10.  
  11. it only took me about 3 hours to get the wonderful results below.
  12.  
  13. Results (on a 400 X 400 sample):
  14.  
  15. Optimized C (Built PPC):                0.900 seconds
  16. Optimized REALbasic (Built PPC):   0.916 seconds
  17. Non opt.    REALbasic (Built PPC):     6.483 seconds
  18.  
  19. Tests were run on a 400 MHz G4, VM on.
  20. C compiled with Metrowerks Codewarrior 4.02
  21. REALbasic apps built with 2.1 beta 5
  22. All tests were run with threading turned off.
  23.  
  24. Note: This example compiles for 68k and Win32 just fine.  In Win32 the drag and drop doesn't work.
  25.  
  26. Cortis Clark
  27. --
  28. cortis@realsoftware.com
  29. Programming Lead @ REAL Software
  30.